<template>
  <div class="asset-list">
    <template v-if="list.length > 0">
    <div class="item" v-for="(item, index) in list" :key="index">
      <div class="title">
        <span :class="`tag-${item.borrowState} tag`">{{
          getStatus(item.borrowState)
        }}</span>
        <span class="name">{{ item.assetName }}</span>
      </div>
      <div class="label">
        <span class="title">资产数字ID</span>
        <span class="name">{{ item.assetCode }}</span>
      </div>
      <div class="label">
        <span class="title">资产分类</span>
        <span class="name">{{ item.className }}</span>
      </div>
      
    </div>
  </template>
  <template v-else><no-data></no-data></template>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default: [],
    },
  },
  methods: {
    getStatus(state) {
      let text = "未出借";
      switch (state) {
        case 0:
          text = "未出借";
          break;
        case 1:
          text = "出借待确认";
          break;
        case 2:
          text = "出借中";
          break;
        case 3:
          text = "归还待确认";
          break;
        default:
          text = "未出借";
          break;
      }
      return text;
    },
  },
};
</script>

<style lang="less" scoped>
.asset-list {
  height: auto;
  background: #f1f1f1;
  padding: 10px;
  .item {
    padding: 10px 15px;
    border-radius: 8px;
    background: #fff;
    margin-bottom: 10px;

    .title {
      height: 30px;
      line-height: 30px;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      position: relative;
      .tag {
        color: #fff;
        position: relative;
        display: inline-block;
        padding: 0 3px 0 6px;
        font-size: 12px;
        line-height: 20px;
        height: 20px;
        border-radius: 4px 0 0 4px;
        &::after {
          border-left: 10px solid transparent;
          border-right: 10px solid transparent;
          //   border-top: 8px solid red;
          content: "";
          position: absolute;
          top: 6px;
          right: -14px;
          width: 0;
          z-index: 99;
          -webkit-transform: rotate(270deg);
          transform: rotate(270deg);
        }
      }
      .tag-1,
      .tag-1 {
        background: rgb(87, 184, 135);
        &::after {
          border-top: 8px solid rgb(87, 184, 135);
        }
      }
      .tag-2 {
        background: rgb(53, 120, 230);
        &::after {
          border-top: 8px solid rgb(53, 120, 230);
        }
      }
      .tag-3 {
        background: rgb(240, 153, 82);
        &::after {
          border-top: 8px solid rgb(240, 153, 82);
        }
      }
      .name {
        display: inline-block;
        margin-left: 20px;
      }
      .more {
        position: absolute;
        right: 0px;
      }
    }

    .label {
      display: flex;
      justify-content: flex-start;
      height: 30px;
      line-height: 30px;
      color: rgb(127, 127, 127);

      .title {
        display: inline-block;
        width: 100px;
      }
    }
  }
}
</style>
